package month4.day19;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FirmMap {
    private String name;
    private String site;
    private String telephone;
    private String range;
    //招聘员工（要求工号不能重复）
    Map<String, Staff> list = new HashMap<>();

    public boolean add(String name, Staff staff) {
        if (list.containsKey(name)) {
            System.out.println("工号重复");
            return false;
        }
        System.out.println("招聘成功");
        list.put(name, staff);
        return true;
    }

    //输出员工信息
    public void show() {
        for (Staff valeu : list.values())
            System.out.println("员工姓名：" + valeu.getName() + "员工年龄：" + valeu.getAge() + "员工性别：" + valeu.getSex() + "员工职位：" + valeu.getDuty() + "员工薪水：" + valeu.getMoney() + "员工工号：" + valeu.getNumber());
    }

    //辞退员工
    public boolean refuse(String number) {
        if (list.containsKey(number)) {
            list.remove(number);
            return true;
        } else
            return false;
    }

    //公司人数
    public int count() {
        return list.size();
    }

    //薪水最高的员工
    public Staff staff() {
        Staff sf = new Staff();
        sf.setMoney(0);
        if (list.isEmpty())
            return null;
        for (Object o : list.values()) {
            Staff staff = (Staff) o;
            if (staff.getMoney() > sf.getMoney())
                sf = staff;
        }
        return sf;
    }

    public FirmMap(String name, String site, String telephone, String range) {
        this.name = name;
        this.site = site;
        this.telephone = telephone;
        this.range = range;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getRange() {
        return range;
    }

    public void setRange(String range) {
        this.range = range;
    }


}
